package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username} and status = 1")
    Employee getByUsername(String username);

    /**
     * 按姓名选择员工
     *
     * @param name 姓名
     * @return {@link List}<{@link Employee}>
     */
    List<Employee> selectEmployeeByName(String name);

    /**
     * 更新员工状态
     *
     * @param id     id
     * @param status 状态
     */
    void updateEmployeeStatus(Integer id, Integer status);

    /**
     * 按id查询员工
     *
     * @param id id
     * @return {@link Employee}
     */
    Employee queryEmployeeById(Long id);

    /**
     * 更新员工
     *
     * @param employee 员工dto
     */
    void updateEmployee(Employee employee);

    /**
     * 保存员工
     *
     * @param employee 员工
     */
    @AutoFill(OperationType.INSERT)
    void saveEmployee(Employee employee);

    /**
     * 按用户名选择不是id计数
     *
     * @param id       id
     * @param username 用户名
     * @return {@link Integer}
     */
    Integer selectByUserNameIsNotIdCount(Long id, String username);
}
